package com.sx.service.serviceImpl;

import com.sx.controller.OptionRecord;
import com.sx.dao.*;
import com.sx.dao.daoImpl.*;
import com.sx.pojo.OptionRecords;
import com.sx.service.OptionRecordService;
import com.sx.utils.DatabaseUtil;
import com.sx.utils.GetOptionRecordID;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class OptionRecordServiceImpl implements OptionRecordService {
    private final OptionRecordDao optionRecordDao = new OptionRecordDaoImpl();
    private final GoodDao goodDao = new GoodDaoImpl();
    private final SupplierDao supplierDao = new SupplierDaoImpl();
    private final CategoryDao categoryDao = new CategoryDaoImpl();
    private final PersonDao personDao = new PersonDaoImpl();
    private final SaleBillDao saleBillDao = new SaleBillDaoImpl();

    @Override
    public void addOptionRecord(String PersonId, String personName, String BeOption, String AfOption, int flag, int type) {
        //获取当前操作记录id
        String operationRecordId = GetOptionRecordID.generateOperationRecordId();
        //获取当前操作时间
        //如何将商品添加记录
        //定义添加Sql语句
        //获取当前时间
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 定义日期时间格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String format = now.format(formatter);
        LocalDateTime dateTime = LocalDateTime.parse(format, formatter);
        //添加操作记录
        optionRecordDao.addOptionRecord(operationRecordId, PersonId, personName, BeOption, AfOption, dateTime, flag, type);
    }

    @Override
    public ArrayList<OptionRecords> getAllOptionRecord() {
        return optionRecordDao.getAllOptionRecord();
    }

    @Override
    public boolean deleteOptionRecordById(String id) {
        return optionRecordDao.deleteOptionRecordById(id);
    }

    @Override
    public List<OptionRecords> getFilteredOptionRecords(String startDate, String endDate, String operatorId, String operationType, String tableType) {
        return optionRecordDao.getFilteredOptionRecords(startDate, endDate, operatorId, operationType, tableType);
    }

    @Override
    public List<OptionRecords> getOptionRecords(OptionRecords o, int i, int i1) {
        return List.of();
    }

   /* @Override
    public void addOptionRecord(String PersonId, String name,String  int flag, String id, int type) {
        //获取操作记录表的id
        String operationRecordId = GetOptionRecordID.generateOperationRecordId();

    }*/
}
